package com.jd.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

import javax.sql.DataSource;

@Component
@PropertySource("class:jdbc.properties")
public class jdbcConfig {
@Value("com.mysql.cj.jdbc.Driver")
    private  String driver;
@Value("jdbc:mysql:///bookstore")
private  String url;
@Value("root")
private  String username;
@Value("123456")
private  String password;
@Bean
    public DataSource dataSource(){
     DruidDataSource dataSource=new DruidDataSource();
     dataSource.setDriverClassName(driver);
     dataSource.setUrl(url);
     dataSource.setUsername(username);
     dataSource.setPassword(password);
     return  dataSource;
}



}
